import { useRecentPlayStore } from "@/store/useRecentPlayStore";
import { isDevMode } from "@/utils/env";
export const usePlay = () => {
  const { addPlayGame } = useRecentPlayStore();
  const play = (game: any) => {
    if (!unref(game)) return;
    // 添加到最近游玩列表
    addPlayGame(unref(game));
    // 这里可以添加其他的逻辑，比如跳转到游戏详情页等
    if (unref(game)?.url) {
      const link = isDevMode()
        ? "https://test.beaconeyes.com" + unref(game)?.url
        : location.origin + unref(game)?.url;
      location.href = link;
    }
  };
  return {
    play,
  };
};
